﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Senparc.Weixin.Exceptions;
using Senparc.Weixin.MP.AdvancedAPIs;
using Senparc.Weixin.MP.AdvancedAPIs.OAuth;
using Senparc.Weixin.MP.CommonAPIs;
using System.Web.Configuration;
using Senparc.Weixin.MP;

namespace Superstore.Vender.Controllers
{
    public class AuthController : Controller
    {
        private static readonly string AppId = WebConfigurationManager.AppSettings["WeixinAppId"];//与微信公众账号后台的AppId设置保持一致，区分大小写。
        private static readonly string AppSecret = WebConfigurationManager.AppSettings["WeixinAppSecret"];//与微信公众账号后台的AppSecret设置保持一致，区分大小写。

        public static readonly string AuthorizeState = "Vender";
        // GET: Auth
        public ActionResult Index(string returnUrl)
        {
            //获取用户详细信息 需要用户同意
            //string url = = OAuthApi.GetAuthorizeUrl(AppId, returnUrl, AuthController.AuthorizeState, OAuthScope.snsapi_userinfo);
            //获取用户openId 静默授权获取
            string url = OAuthApi.GetAuthorizeUrl(AppId, returnUrl, AuthController.AuthorizeState, OAuthScope.snsapi_base, "SuperStore");
            return Redirect(url);
        }
    }
}